package com.book.bookprojectapplication.write.fragment;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.book.bookprojectapplication.R;
import com.book.bookprojectapplication.write.activity.WriteDecorateActivity;

public class WriteDecoBgFragment extends Fragment implements OnClickListener {
	ImageView writeDecoBgImg1, writeDecoBgImg2, writeDecoBgImg3;
	Bitmap writeDecoBgbm1, writeDecoBgbm2, writeDecoBgbm3, resize;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		System.out.println("WriteDecoBgFragment onCreateView() start");

		View view = inflater.inflate(R.layout.fragmentwritedecobg, container, false);
		
		
		writeDecoBgImg1 = (ImageView) view.findViewById(R.id.writedecobg1);
		writeDecoBgImg2 = (ImageView) view.findViewById(R.id.writedecobg2);
		writeDecoBgImg3 = (ImageView) view.findViewById(R.id.writedecobg3);
		

		writeDecoBgbm1 = BitmapFactory.decodeResource(getResources(),
				R.drawable.sample_1);
		resize = Bitmap.createScaledBitmap(writeDecoBgbm1, 50, 100, true);
		writeDecoBgImg1.setImageBitmap(resize);

		writeDecoBgbm2 = BitmapFactory.decodeResource(getResources(),
				R.drawable.sample_2);
		resize = Bitmap.createScaledBitmap(writeDecoBgbm2, 50, 100, true);
		writeDecoBgImg2.setImageBitmap(resize);

		writeDecoBgbm3 = BitmapFactory.decodeResource(getResources(),
				R.drawable.sample_3);
		resize = Bitmap.createScaledBitmap(writeDecoBgbm3, 50, 100, true);
		writeDecoBgImg3.setImageBitmap(resize);

		writeDecoBgImg1.setOnClickListener(this);
		writeDecoBgImg2.setOnClickListener(this);
		writeDecoBgImg3.setOnClickListener(this);

		return view;
	}

	@Override
	public void onClick(View v) {
		System.out.println("bgbtn click");
		switch (v.getId()) {
		case R.id.writedecobg1:
			System.out.println("sample1 click");
			WriteDecorateActivity.setBackgroundEdit(R.drawable.sample_1);
			break;
		case R.id.writedecobg2:
			System.out.println("sample2 click");
			WriteDecorateActivity.setBackgroundEdit(R.drawable.sample_2);
			break;
		case R.id.writedecobg3:
			System.out.println("sample3 click");
			WriteDecorateActivity.setBackgroundEdit(R.drawable.sample_3);
			break;
		}

	}
}
